<?php
/**
 * Partial:
 * Beinhaltet Hilfsroutinen
 *
 * @author		Joachim Ruf
 * @copyright	Copyright (c) 2003-2013 Loresoft Software (http://www.loresoft.de)
 * @license		http://yapary.loresoft.de/lizenzbedingungen     New BSD License
 *
 * */


Class Yapary_MVC_SimpleMVC_Partial
{
	protected $registry;
	private $pathPartial = NULL;


    /**
	* @desc Yapary_MVC_SimpleMVC_Partial
	*/
    function __construct ($_pathPartial) {
    	$this->registry			= Yapary_MVC_SimpleMVC_Registry::getInstance();
    	$this->pathPartial		= $_pathPartial;
    }


	/**
	* Laedt das angegebene Partial
	* @param string $pathPartial : Pfad zum Partial inklusive Dateiendung
	* @param array $arrVariable : Mitzuliefernde Werte array('varName1'=>val1, 'varName2'=>val2, ...)
	* @return string
	*/
    public function insert ($fileName, array $arrVars = array())
    {
	    $result = '';

	    try {
	    	if (count($arrVars) >= 1) {
	    		while (list($key, $val) = each($arrVars)) {
	    			$$key = $val;
	    		}
	    	}

            ob_start();
			include($this->pathPartial.'partial/'.$fileName);
            $result = ob_get_contents();
            ob_end_clean();
	    } catch (Exception $e) {
	    	throw $e;
	    }

		return $result;
    }


}

?>